Skip to content

fix(android): clean up pending camera temp files on cancel/stop - #970

Open
GitToTheHub wants to merge 1 commit into
masterfrom
pr-android-cleanup-files-after-cancel-stop
Open

GitToTheHub wants to merge 1 commit into
masterfrom
pr-android-cleanup-files-after-cancel-stop

Conversation

@GitToTheHub

@GitToTheHub GitToTheHub commented Jul 31, 2026 •

Copy link
Copy Markdown
Contributor

Platforms affected

Android

Motivation and Context

Follow up of PR #873.

@erisu noticed after PR #873 was merged, if there should be any cleanup procedures after stop was called. For example when takePicture is executed this.imageUri is set and gets not cleared. After checking this, it turned out, that this is the case, but this was also true, when an Activity was canceled by the user. This fixes both cases.

Description

  • delete pending image and cropped temp files when camera flow is stopped
  • run cleanup when image selection/capture is canceled
  • reset pending URI and file path state after best-effort cleanup

Generated-By: GPT-5.3-Codex

Testing

Checklist

  • I've run the tests to see all new and existing tests pass
  • I added automated test coverage as appropriate for this change
  • Commit is prefixed with (platform) if this change only applies to one platform (e.g. (android))
  • If this Pull Request resolves an issue, I linked to the issue in the text above (and used the correct keyword to close issues using keywords)
  • I've updated the documentation if necessary

- delete pending image and cropped temp files when camera flow is stopped
- run cleanup when image selection/capture is canceled
- reset pending URI and file path state after best-effort cleanup

Generated-By: GPT-5.3-Codex
* Best-effort cleanup for temporary files when capture/selection is cancelled or stopped.
*/
private void cleanupPendingResultFiles() {
deleteIfExists(this.imageUri);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the imageUri contains a content:// URI, and the deleteIfExists method which uses new File(filePath).delete() would not work as it expects a filesystem path.

I believe we would need to use the ContentResolver to delete the file by passing in the imageUri.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants